<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Links extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->library('output');
        $this->output->nocache();

        // check if already logged in
        if ( ! $this->session->userdata('logged_in_user'))
        {
            redirect('login');
        }
    }

    /**
     * Display link form
     * @return void
     */
    public function index()
	{
        $this->load->model('linkmodel');
        $this->load->library("pagination");
        $this->load->config("pagination");

        $page_info['title'] = 'Link Management :: Robi CMS';
        $page_info['url_suffix'] = $this->config->item('url_suffix');
        $page_info['view_page'] = 'administrator/link_management';
        $page_info['message_error'] = '';

        // get paginated list
        $config = array();
        $config["base_url"] = base_url() . "administrator/links";
        $config["total_rows"] = $this->linkmodel->num_of_records();
        $perpage = $this->config->item('per_page');
        $uri_segment = $this->config->item('uri_segment');

        $this->pagination->initialize($config);
        $page = ($this->uri->segment($uri_segment)) ? $this->uri->segment($uri_segment) : 0;

        $page_info['records'] = $this->linkmodel->get_links($perpage, $page);
        $page_info['links'] = $this->pagination->create_links();

        
        if ($this->session->flashdata('message_error'))
        {
            $page_info['message_error'] = $this->session->flashdata('message_error');
        }

		$this->load->view('administrator/layouts/default', $page_info);
	}

}

/* End of file links.php */
/* Location: ./application/controllers/administrator/links.php */